"""定义递归函数"""


# fibo 函数 1 1 2 3 5 8
def fibo(num):
    if num == 0 or num == 1:
        return 1
    return fibo(num - 1) + fibo(num - 2)


x = fibo(5)
print(x)


# 阶乘函数
def fact(n):
    if n == 1:
        return 1
    return n * fact(n - 1)


y = fact(5)
print(y)


# 使用递归定义一个字符串反转函数
def reverse(s):
    if len(s) <= 1:
        return s
    return reverse(s[1:]) + s[0]


s1 = reverse('sml')
print(s1)
